package com.desire.config;

import com.desire.config.autoconfig.TokenProperties;
import com.desire.interceptor.TokenInterceptor;
import com.desire.utils.TokenUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author LittleDesire
 * @description
 * @date 2022-05-09 周一 15:06
 * @since 17
 */
public class TokenInterceptorRegistry implements WebMvcConfigurer {
    @Autowired
    TokenProperties properties;

    @Autowired
    TokenInterceptor tokenInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(tokenInterceptor)
                .excludePathPatterns(properties.getExcludePathPatterns())
                .addPathPatterns(properties.getPathPatterns());
    }
}
